/**
 * @description theme
 * @author Zhangbin
 */
import { message } from 'ant-design-vue';

/**
 * @description change theme
 * @param {vars} object
 * @param {flag} string
 */
export const changeTheme = (vars: any, flag: string, theme?: string): void => {
  (window as any).less
    .modifyVars(vars)
    .then((res: any) => {
      if(flag === 'isChange') {
        message.destroy();
        message.success((vars['primary-color'] || theme) + ' Theme Change Success!!')
      }
    })
    .catch((res: any) => {
      message.error('Theme Change Fail!!')
    })
    ;
}